﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Barbar.Colonization.Model {
  public class Building : Entity, IStepExecute {
    private BuildingType m_BuildingType;
    private City m_City;

    public BuildingType BuildingType {
      get { return m_BuildingType; }
      protected set { m_BuildingType = value; }
    }

    public City City {
      get { return m_City; }
      protected set { m_City = value; }
    }

    #region IStepExecute Members

    public virtual void ExecuteStep() {
      FactoryType factotyType = m_BuildingType as FactoryType;
      if (factotyType != null) {
        if (factotyType.Consuming != null) {
          if (City.Store.Consume(factotyType.Consuming)) {
            City.Store.Produce(factotyType.Producing);
          }
        }
      }
    }

    #endregion
  }
}
